import { createRouter, createWebHistory, RouteLocationNormalized, RouteRecordRaw } from 'vue-router'
import { useTitle } from '@vueuse/core'
import { getCookie } from '@/utils/auth'
import { useStore } from "@/store/user";

import { ElMessage } from 'element-plus';

import Layout from '@/layouts/index.vue'
import baseRouters from './modules/baseRouters';

//动态路由
export const asyncRouterList: Array<RouteRecordRaw> = [...baseRouters];

export const page404 = {
    path: '/:w+',
    name: '404Page',
    component: () => import(/* webpackChunkName: "Home" */ '@/views/error/404.vue')
};

/**
 * 固定路由
 */
const defaultRouterList: Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'Home',
        component: Layout,
        redirect: '/index',
        children: [
            {
                path: 'index',
                name: 'Index',
                component: () => import(/* webpackChunkName: "Home" */ '@/views/index.vue'),
                meta: { title: '首页' }
            },
            {
                path: 'about',
                name: 'About',
                component: () => import(/* webpackChunkName: "About" */'@/views/About.vue'),
                meta: { title: '关于' }
            },
            {
                path: '/user',
                name: 'User',
                component: () => import(/* webpackChunkName: "User" */'@/views/user/index.vue')
            },
            {
                path: '/dept',
                name: 'dept',
                component: () => import(/* webpackChunkName: "dept" */'@/views/dept/index.vue')
            }
        ]
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import(/* webpackChunkName: "Login" */'@/views/Login.vue')
    },
    {
        ...page404
    }
]



const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: defaultRouterList,
    scrollBehavior() {
        return {
            el: '#app',
            top: 0,
            behavior: 'smooth',
        };
    }
})

let startTime = Date.now()
let currentTime: number;



export default router
